﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace _4_1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
           
        }

        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {

        }

        private void Form1_Load(object sender, EventArgs e)
        { 
            // 初始化硬盘选项
            comboBox1.Items.Add("256GB SSD");
            comboBox1.Items.Add("512GB SSD");
            comboBox1.Items.Add("1TB HDD");
            comboBox1.Items.Add("2TB HDD");
            comboBox1.SelectedIndex = 0;

        }

        private void groupBox1_Enter(object sender, EventArgs e)
        {

        }

        private void radioButton1_CheckedChanged(object sender, EventArgs e)
        {

        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            // 检查内存输入是否合法
            try
            {
                int memory = int.Parse(textBox1.Text);
                if (memory <= 0)
                {
                    MessageBox.Show("内存大小必须大于0！", "输入错误");
                    textBox1.Focus();
                    textBox1.SelectAll();
                }
            }
            catch
            {
                MessageBox.Show("请输入有效的数字！", "输入错误");
                textBox1.Focus();
                textBox1.SelectAll();
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            // 生成配置清单
            listBox1.Items.Clear();
            listBox1.Items.Add("=== 计算机配置清单 ===");

            // CPU配置
            string cpu = "";
            if (radioButton1.Checked) cpu = "Intel i5";
            else if (radioButton2.Checked) cpu = "Intel i7";
            else if (radioButton3.Checked) cpu = "AMD Ryzen 5";
            else if (radioButton4.Checked) cpu = "AMD Ryzen 7";
            listBox1.Items.Add("CPU: " + cpu);

            // 内存配置
            listBox1.Items.Add("内存: " + textBox1.Text + "GB");

            // 硬盘配置
            listBox1.Items.Add("硬盘: " + comboBox1.SelectedItem.ToString());

            // 配件配置
            listBox1.Items.Add("配件:");
            if (checkBox1.Checked) listBox1.Items.Add("  - 显示器");
            if (checkBox2.Checked) listBox1.Items.Add("  - 键盘");
            if (checkBox3.Checked) listBox1.Items.Add("  - 鼠标");
            if (checkBox4.Checked) listBox1.Items.Add("  - 音箱");
        }
    }
}
